package com.wpml.ware.controller;

import com.wpml.common.util.PageUtils;
import com.wpml.common.util.ResultJson;
import com.wpml.ware.entity.PurchaseDetailModel;
import com.wpml.ware.service.PurchaseDetailService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Map;


/**
 *
 *
 * @author leifengyang
 * @email leifengyang@gmail.com
 * @date 2019-11-17 13:50:10
 */
@RestController
@RequestMapping("ware/purchasedetail")
public class PurchaseDetailController {
    @Resource
    private PurchaseDetailService purchaseDetailService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("ware:purchasedetail:list")
    public ResultJson list(@RequestParam Map<String, Object> params){
        PageUtils page = purchaseDetailService.queryPage(params);

        return ResultJson.ok(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("ware:purchasedetail:info")
    public ResultJson info(@PathVariable("id") Long id){
        PurchaseDetailModel purchaseDetail = purchaseDetailService.getById(id);

        return ResultJson.ok(purchaseDetail);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("ware:purchasedetail:save")
    public ResultJson save(@RequestBody PurchaseDetailModel purchaseDetail){
		purchaseDetailService.save(purchaseDetail);

        return ResultJson.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    //@RequiresPermissions("ware:purchasedetail:update")
    public ResultJson update(@RequestBody PurchaseDetailModel purchaseDetail){
		purchaseDetailService.updateById(purchaseDetail);

        return ResultJson.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    //@RequiresPermissions("ware:purchasedetail:delete")
    public ResultJson delete(@RequestBody Long[] ids){
		purchaseDetailService.removeByIds(Arrays.asList(ids));

        return ResultJson.ok();
    }

}
